import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Badge extends StatelessWidget {
  int num;
  Badge({
    Key key,
    @required this.num
  }):super(key:key);
  @override
  Widget build(BuildContext context) {
    if (num != null && num != 0) {
      var width;
      if (num < 10) { width = 34;}
      else if (num < 100) {width = 48;}
      else if (num >= 100) {width = 58;}
      return Padding(
        padding: EdgeInsets.only(
          top: ScreenUtil().setWidth(0),
          left: ScreenUtil().setWidth(5),
        ),
        child: Container(
          alignment: Alignment(0.0, 0.5),
          width: ScreenUtil().setWidth(width),
          height: ScreenUtil().setWidth(34),
          decoration: BoxDecoration(
            color: Color.fromRGBO(236, 108, 85, 1),
            borderRadius: BorderRadius.circular(50)
          ),
          child: Text(
            num >= 100 ? '99+' : num.toString(),
            style: TextStyle(
              fontSize: ScreenUtil().setWidth(24),
              color: Colors.white
            ),
          ),
        ),
      );
    } else {
      return Container(width: 0,height: 0);
    }

  }
}